package com.xz.courseschedule.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
*@Author: zys
*@CreateTime: 2025-05-22
*/
@TableName("semester")
@Data
public class Semester implements Serializable {

    @TableId(type = IdType.AUTO)
    private Long id;

    private String semesterName;//学期名

    private Integer semesterWeeksSum;//学期总周数

    private LocalDate semesterStartDate;//学期开始日(必须是星期一)

    private LocalDate semesterEndDate;//学期结束日

    private Integer semesterStatus;//是否已排课 0未排课 1已排课

    private Long createdBy;//创建人

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createdTime;//创建时间

    private Long updatedBy;//修改人

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime updatedTime;//修改时间

    //通过开始日和总周数，自动计算结束日
    public void setSemesterEndDate() {
        this.semesterEndDate = semesterStartDate.plusWeeks(semesterWeeksSum);
    }
}
